package com.local.web.service.impl;

import com.local.carousel.feign.CarouselServiceFeign;
import com.local.carousel.pojo.Carousel;
import com.local.common.constants.BusinessException;
import com.local.common.util.ResultUtil;
import com.local.web.service.CarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarouselServiceImpl implements CarouselService {

    @Autowired
    private CarouselServiceFeign carouselServiceFeign;

    /**
     * 查询轮播图（用于网站首页）
     * @return
     */
    @Override
    public List<Carousel> getCarouselList() {
        ResultUtil<List<Carousel>> carouselListResult = carouselServiceFeign.getCarouselList();
        if (carouselListResult.getCode() != 200) {
            throw new BusinessException(carouselListResult.getCode(), carouselListResult.getMessage());
        }
        List<Carousel> data = carouselListResult.getData();
        return data;
    }
}
